home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.tar / ftp.whtech.com / datasheets and manuals / Hardware / WHT / scsi / dsr_sources_2_2001 / restore < prev    next >
Text File  |  2006-10-19  |  2KB  |  96 lines

  1. **
  2. *
  3. *  I/O Op Code 6 - RESTORE
  4. *
  5. *  This routine will reset the file pointers.  If the record
  6. *  number is nonzero and the file was opened for relative
  7. *  access, the file pointer will be set to the specified
  8. *  record.  Otherwise, it will reset to the beginning of
  9. *  the file.
  10. *
  11. **
  12.  
  13. REST0  ANDI R12,>FF00
  14.        AI   R12,24
  15.  
  16.        LDCR @B02,4
  17.        BLWP @IFO             Check to make sure file is open
  18.        JEQ  REST2
  19.  
  20. REST1  BL   @DSRERR
  21.        DATA >0700            File error
  22.  
  23. REST2
  24.  
  25. * If file was open for output or append, error!
  26. *
  27.        CB   @56(R5),@B01
  28.        JEQ  REST1
  29.  
  30.        CB   @56(R5),@B04
  31.        JEQ  REST1
  32.  
  33. * If no record number is given, go to the beginning of the file
  34. *
  35.  
  36.        LDCR @ZERO,4
  37.        MOV  @PABBUF+6,R1
  38.        JNE  REST10
  39.  
  40. * We will check to see if the 1st sector of the file is in
  41. * the buffer.  If it is, we won't destroy it completely to
  42. * save reading the sector back in later.
  43. *
  44.  
  45.        LDCR @B02,4
  46.        MOV  @4(R5),R2        Get FDR address
  47.        LDCR @2(R5),4
  48.        MOV  @40(R2),R10      Get 1st AU of file
  49.        JEQ  REST5
  50.  
  51.        LDCR @B02,4
  52.        C    R10,@50(R5)
  53.        JNE  REST5
  54.        C    @ZERO,@52(R5)
  55.        JNE  REST5
  56.  
  57. REST3  MOV  @6(R5),@54(R5)   Reset pointer in buffer
  58.        CLR  @62(R5)          Reset record number
  59.        LDCR @2(R5),4         If variable length files,
  60.        MOVB @12(R2),R3       set sector number to 1
  61.        ANDI R3,>8000
  62.        JEQ  REST4
  63.        LDCR @B02,4
  64.        C    @ZERO,@50(R5)
  65.        JEQ  REST4
  66.        INC  @62(R5)
  67. REST4  LDCR @ZERO,4
  68.        B    @DSRRT
  69.  
  70. REST5  CLR  @50(R5)          Reset current AU
  71.        CLR  @52(R5)          Reset sector within AU
  72.        JMP  REST3
  73.  
  74. **
  75. *
  76. *  Here we reset to a specific record number.  Make sure
  77. *  the file was opened for relative access, then position
  78. *  to that record number.
  79. *
  80. *  If the record isn't in the current buffer, we call FLUSH
  81. *  to make sure we write out any updated information.
  82. *
  83. **
  84.  
  85. REST10
  86.        LDCR @B02,4           Select RAM bank 2
  87.        MOVB @57(R5),R1       Check for relative access
  88.        JNE  REST11
  89.  
  90.        BL   @DSRERR
  91.        DATA >0700            File error
  92. REST11
  93.        BL   @POSIT           Position the file pointer
  94.        LDCR @ZERO,4
  95.        B    @DSRRT
  96.